package top.eggcode.common.model;

/**
 * Title:
 * Description: TODO
 * Date: 2021/9/17 19:46
 *
 * @author JiaQi Ding
 * @version 1.0
 */
public class PageQuery implements Pageable {

    private static final long serialVersionUID = 1L;

    /**
     * 从 1 开始
     */
    protected long pageNumber = 1;

    protected long pageSize = 10;

    protected String sort;

    @Override
    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    @Override
    public boolean hasPrevious() {
        return false;
    }

    /**
     * 从 0 开始
     *
     * @return
     */
    @Override
    public long getPageNumber() {
        return pageNumber;
    }

    @Override
    public long getPageSize() {
        return pageSize;
    }

    public void setPageNumber(long pageNumber) {
        this.pageNumber = pageNumber;
    }

    public void setPageSize(long pageSize) {
        this.pageSize = pageSize;
    }

    @Override
    public long getOffset() {
        return pageSize * (getPageNumber() - 1);
    }
}
